package com.fantasy.readproperties;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Properties;

import com.fantasy.file.GetFolderAbsPath;

public class ReadProperties {

	public static Properties read(String fileName) {

		Properties configure;
		configure = new Properties();
		String filePath = GetFolderAbsPath.getPath();
		try {
			filePath = filePath + fileName;
			InputStream inputStream = new FileInputStream(new File(filePath));
			configure.load(inputStream);
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return configure;
	}

	public static String getProperty(String fileName , String Property) {
		String res = read(fileName).getProperty(Property);
		if(res == null){
			res = "";
		}
		return res;
	}
	
	public static void ProToList(Properties properties) {
		Enumeration<?> enu = properties.propertyNames();
		while (enu.hasMoreElements()) {
			Object key = enu.nextElement();
			System.out.println(key);
		}
	}

}
